<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
</head>

<body>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    apiready = function() {
        api.openWin({
            name: 'main',
            url: './html/main.html',
            slidBackEnabled: false,
            pageParam: {
                name: 'test'
            }
        });
        // var ajpush = api.require('ajpush');
        // if (api.systemType == "android") {
        //     ajpush.init(function(ret) {
        //         var param = {
        //             alias: 'user1',
        //             tags: ['user']
        //         };
        //         ajpush.bindAliasAndTags(param, function(ret) {});
        //         ajpush.setListener(jpushListener);
        //     });
        // } else if (api.systemType == "ios") {
        //     ajpush.setListener(jpushListener);
        //     var param = {
        //         alias: 'user2',
        //         tags: ['user']
        //     };
        //     ajpush.bindAliasAndTags(param, function(ret) {});
        // }
        // //获取用户的设备id，上传到服务器；
        // ajpush.getRegistrationId(function(ret) {
        //     var registrationId = ret.id;
        //     alert(registrationId);
        // });
        //
        // function jpushListener(ret) {}

    };
</script>
<!-- <script type="text/javascript">
var ajpush;
apiready = function() {
  api.openWin({
      name: 'main',
      url: './html/main.html',
      slidBackEnabled: false,
      pageParam: {
          name: 'test'
      }
  });



  ajpush = api.require('ajpush');
  //我这是标明用户数据状态是2的我才进行推送  按自己需求更改
  if ($api.getStorage("local_user").pushstatus == 2) {
    //初始化极光
    ajpush.init(function(ret) {
      if (ret.status == 1) {
        initajpush()
      }
    });
    if (api.systemType == 'ios') {
      initajpush()
    }
    //因为IOS和andriod监听不同所以我这里不同的作了不同的处理
    api.addEventListener({
      name : 'noticeclicked'
    }, function(ret, err) {
      if (ret && ret.value) {
        var ajpush = ret.value;
        var content = ajpush.content;
        var extra = ajpush.extra;
        redirect(extra.pushStatus)
      }
    })
    api.addEventListener({
      name : 'appintent'
    }, function(ret, err) {
      if (ret && ret.appParam.ajpush) {
        var ajpush = ret.appParam.ajpush;
        var id = ajpush.id;
        var title = ajpush.title;
        var content = ajpush.content;
        var extra = ajpush.extra;
        redirect(JSON.parse(extra).pushStatus)
      }
    })
  }
  init()
};

function initajpush() {
  var param = {
    alias : "p" + $api.getStorage("local_user").id,
    tags : [ "p" + $api.getStorage("local_user").id ]
  };
  //绑定别名
  ajpush.bindAliasAndTags(param, function(ret) {
    var statusCode = ret.statusCode;
    api.toast({
      msg : '初始化极光成功'
    });
  });
}
function redirect(num) {
  switch (num) {
  case 1:
    openWin('work', 'recipelist')
    break;
  case 2:
    randomSwitchBtn('doctor', 3)
    break;
  case 3:
    randomSwitchBtn('doctor', 3)
    break;
  default:
    break;
  }
}

function init() {
  ajax('后台url', {
    id : $api.getStorage("local_user").id
  }, function(ret, err) {
    if (ret) {
      if (ret.status == "success") {
        if (ret.result.directStatus == 1) {
          api.openFrame({
            name : 'dzpage',
            url : 'widget://html/zdpage.html'
          });
        } else {
          randomSwitchBtn(api.pageParam.tagName || 'uc',
              api.pageParam.tagNum || 0)
        }
      } else {
        sysAlert(ret.msg);
      }
    }
  });
}


</script> -->

</html>
